import 'package:flutter/material.dart';
import 'package:flutter_deer/account/iview/agent_user_betting_list_iview.dart';
import 'package:flutter_deer/index/models/user_betting_entity.dart';
import 'package:flutter_deer/mvp/base_page_presenter.dart';
import 'package:flutter_deer/net/base_entity.dart';
import 'package:flutter_deer/net/dio_utils.dart';
import 'package:flutter_deer/net/http_api.dart';
import 'package:flutter_deer/res/constant.dart';
import 'package:flutter_deer/util/other_utils.dart';


class AgentUserBettingListPresenter extends BasePagePresenter<AgentUserBettingListIMvpView> {

  @override
  void initState() {
  }

  Future<dynamic> getUserBettingList(String? status,String? username) async {
    WidgetsBinding.instance.addPostFrameCallback((_) {
      final Map<String, dynamic> params = <String, dynamic>{};
      params['size'] = Constant.pageSize;
      params['current'] = 1;
      asyncRequestNetwork<BaseEntity<UserBettingPageEntity>>(Method.get,
        url: HttpApi.agentUserBettingList.replaceAll('{username}', username.nullSafe).replaceAll('{status}', status.nullSafe),
        queryParameters: params,
        onSuccess: (data) {
          view.setUserBettingPage(data!.data);
        },
        onError: (code,msg){

        }
      );
    });
  }

  Future<dynamic> getMoreUserBettingList(String? status,String? username,int? pageNo) async {
    WidgetsBinding.instance.addPostFrameCallback((_) {
      final Map<String, dynamic> params = <String, dynamic>{};
      params['size'] = Constant.pageSize;
      params['current'] = pageNo;
      asyncRequestNetwork<BaseEntity<UserBettingPageEntity>>(Method.get,
          url: HttpApi.agentUserBettingList.replaceAll('{username}', username.nullSafe).replaceAll('{status}', status.nullSafe),
          queryParameters: params,
          onSuccess: (data) {
            view.setUserBettingPage(data!.data);
          },
          onError: (code,msg){

          }
      );
    });
  }
}